<template>
    <div ref="body">
        <Form :label-width="120" inline>

            <Form-item label="属地区划:">
                <area-linkage :areaCode.sync="queryParam.azaa0001"></area-linkage>
            </Form-item>
            <Form-item label="姓名:">
                <Input v-model="queryParam.yjab0001" placeholder="请输入姓名" style="width:200px"/>
            </Form-item>

            <Form-item label="身份证号码:">
                <Input v-model="queryParam.yjab0002" placeholder="请输入身份证号码" style="width:200px"/>
            </Form-item>

            <Form-item label="预警类型:">
                <c-dict-select v-model="queryParam.yjab0003" dictCode="warningtype"/>
            </Form-item>

            <Form-item label="预警类别:">
                <c-dict-select v-model="queryParam.yjab0004" dictCode="warningcategory" show-keys="100,150,200,300,2300,2400,2700"/>
            </Form-item>

            <Form-item label="预警时间:">
                <DatePicker type="daterange" split-panels v-model="queryParam.yjab0005"
                            placeholder="请选择预警时间" style="width: 200px"  :editable="false"></DatePicker>
            </Form-item>

            <Form-item label="办理状态:">
                <Select v-model="queryParam.yjab0006" placeholder="请选择办理状态" style="width:200px">
                    <Option value="100">未办理</Option>
                    <Option value="200">已办理</Option>
                </Select>
            </Form-item>

            <Form-item label="救助类型:">
                <c-dict-select v-model="queryParam.yjab0013" dictCode="systemsubtype"
                               showKeys="1010,1020,1030,1040,1050,1060,1070,1080,1090,3050"/>
            </Form-item>


            <Row class="button_row">
                <span style="float: right;">
                 <Button type="primary" @click="searchQueryNew">查询</Button>
                 <Button type="primary" class="button_item_left" @click="searchResetNew">重置</Button>
                     </span>
            </Row>
        </Form>

        <div class="table_div">
            <vxe-table border
                       auto-resize
                       row-id="id"
                       :row-key="true"
                       show-overflow="tooltip"
                       highlight-hover-row
                       align="center"
                       header-align="center"
                       ref="xTree"
                       :loading="Loading"
                       :data="tableData">
                <vxe-table-column field="yjab0001" title="预警人员姓名" align="center" width="150" fixed="left"/>
                <vxe-table-column field="yjab0002" title="预警人员证件号码" align="center" width="200" fixed="left"/>
                <vxe-table-column field="yjab0014" title="属地区划" align="center" width="220" :formatter="renderAreaName"/>
                <vxe-table-column field="yjab0003" title="预警类型" align="center" width="200"/>
                <vxe-table-column field="yjab0004" title="预警类别" align="center" width="200"/>
                <vxe-table-column field="yjab0005" title="预警时间" align="center" width="200" :formatter="renderTime"/>
                <vxe-table-column field="yjab0006" title="办理状态" align="center" width="200"/>
                <vxe-table-column field="yjab0010" title="家庭编号" align="center" width="200"/>
                <vxe-table-column field="yjab0013" title="救助类型" align="center" width="200"/>
                <vxe-table-column field="createBy" title="发起人" align="center" width="200"/>
                <vxe-table-column field="yjab0007" title="办理人" align="center" width="200"/>
                <vxe-table-column field="yjab0008" title="办理时间" align="center" width="200" :formatter="renderTime"/>
                <vxe-table-column field="yjab0009" title="办理说明" align="center" width="300"/>
                <vxe-table-column title="操作" align="center" width="350" fixed="right" field="do" :visible="true">
                    <template #default="{row}">
                        <Button type="default" @click="finish(row.id)">完成处理</Button>
                        <Button type="default" @click="noMore(row.id)" style="margin-left: 10px">不在提醒</Button>
                        <Button type="default" @click="handleEdit(row)" style="margin-left: 10px">提醒时间调整</Button>
                    </template>
                </vxe-table-column>
            </vxe-table>
            <Page :total="dataCount" :page-size="pageSize" show-total class="paging"
                  @on-change="handleTableChange" :current="pageNo"></Page>
        </div>
        <change-time ref="modalForm" @ok="modalFormOk"/>
    </div>
</template>
<script>
    import {CommonMixin} from '@/views/common/js/CommonMixin'
    import ChangeTime from './modules/ChangeTime'
    import {postAction} from '@/api/request'

    export default {
        name: "ss02011List",
        mixins: [CommonMixin],
        components: {ChangeTime},
        data() {
            return {
                url: {
                    list: "/api/ac/subsistence/Ss02011Service/page",
                    noMore: "/api/ac/subsistence/Ss02011Service/insertNoMore",
                    finish: "/api/ac/subsistence/Ss02011Service/insertFinish",
                },
                Loading: true,
                queryParam: {
                    yjab0006: "100"
                },

            }
        },
        methods: {
            searchResetNew() {
                this.queryParam = {
                    yjab0006: "100"
                };
                this.loadData(1);
            },
            searchQueryNew() {
                var time = this.queryParam.yjab0005;
                if (time) {
                    if (time[0]) {
                        this.queryParam.yjab0005_begin = this.DateFormat(time[0], 'YYYY-MM-DD') + " 00:00:00";
                    }
                    if (time[1]) {
                        this.queryParam.yjab0005_end = this.DateFormat(time[1], 'YYYY-MM-DD') + " 23:59:59";
                    }
                }
                if (this.queryParam.yjab0006 == '200') {
                    this.$refs.xTree.getColumnByField("do").visible = false;
                } else {
                    this.$refs.xTree.getColumnByField("do").visible = true;
                }
                this.$refs.xTree.refreshColumn()
                this.loadData(1);
            },
            finish: function (id) {
                this.$Modal.confirm({
                    title: '确定完成处理吗？',
                    onOk: () => {
                        var that = this;
                        postAction(that.url.finish, {id: id}).then((res) => {
                            if (res.data.errcode == 0) {
                                //重新计算分页问题
                                that.reCalculatePage(1);
                                that.$Message.success("完成处理！");
                            } else {
                                that.$Message.error(res.data.errmsg);
                            }
                        });
                    }
                })
            },
            noMore: function (id) {
                this.$Modal.confirm({
                    title: '确定不再提醒该条预警信息？',
                    onOk: () => {
                        var that = this;
                        postAction(that.url.noMore, {id: id}).then((res) => {
                            if (res.data.errcode == 0) {
                                //重新计算分页问题
                                that.reCalculatePage(1);
                                that.$Message.success("不在提醒！");
                            } else {
                                that.$Message.error(res.data.errmsg);
                            }
                        });
                    }
                })
            },
        },
        created() {
            this.findAreaList();
        },
    }
</script>

<style scoped>

</style>
